<html>
    <body>
        <h1>new 到底做了什么</h1>
        <script>
            // const child = new Parent('mdd',25);
            // console.log(child.name)
            // console.log(child instanceof Parent);
            let b = new Parent('m',25)
            let c = newMethord(Parent,'mdd',25)
            let d = newMethord1(Parent, 'dd',25)
            console.log('b',b,'c',c,'d',d)
            function newMethord(p, ...rest){
                let child =  {};
                p.apply(child,rest)
                child.__proto__ = p.prototype
                return child
            }
            function newMethord1(p, ...rest){
                let child = Object.create(p.prototype); //Object.create()方法创建一个新对象，使用现有的对象来提供新创建的对象的__proto__。 
                p.apply(child,rest);
                return child

            }

            function Parent(name, age){
                console.log("this",this);
                let that = this;
                that.name = name;
                that.age = age;
                return that;
            }
            
        </script>
    </body>
</html>
